// Author: Ivan Chau
package uk.ac.cam.kcic2.scene;

import java.util.ArrayList;

public class Scene {

	public final Colour ambient;
	public final ArrayList<SceneObject> sceneObjects;
	public final ArrayList<LightSource> lights;
	
	public Scene(SceneObject object, int ambientLight, ArrayList<LightSource> sources){
		ambient = new Colour(ambientLight);
		
		sceneObjects = new ArrayList<SceneObject>();
		sceneObjects.add(object);
		
		lights = sources;
	}
	
	public Scene(ArrayList<SceneObject> objects, int ambientLight, ArrayList<LightSource> sources){		
		ambient = new Colour(ambientLight);
		sceneObjects = objects;		
		lights = sources;
	}
	
	public IntersectionInfo getIntersection(Ray ray){
		IntersectionInfo intersection = null;
		for (SceneObject object : this.sceneObjects){
			if (intersection == null){
				intersection = object.getIntersection(ray);
			}
			else if (object.getIntersection(ray) != null && intersection.t > object.getIntersection(ray).t){
				intersection = object.getIntersection(ray);
			}
		}
		return intersection;
	}
}
